package com.morizhang.merchanmanager.api.service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.morizhang.merchanmanager.api.ApiResult;
import com.morizhang.merchanmanager.api.IService;
import com.morizhang.merchanmanager.api.model.CommodityDataModel;
import com.morizhang.merchanmanager.api.plugins.BasicWareManage;
import org.springframework.beans.factory.annotation.Autowired;

@ServiceAnnotation(name = "UpdateCommodityInfoService")
public class UpdateCommodityInfoService implements IService {
    @Autowired
    private BasicWareManage basicWareManage;

    @Override
    public ApiResult callService(JSONObject requestParams) throws Exception {
        CommodityDataModel newCommodityData = JSON.parseObject(requestParams.getJSONObject("data").toJSONString(), CommodityDataModel.class);
        basicWareManage.updateCommodity(newCommodityData);
        ApiResult result = new ApiResult();
        result.setSuccess(true);
        return result;
    }
}
